#ifndef SPRITE__H
#define SPRITE__H

#include <string>

#include "drawable.h"
#include "frame.h"
#include "spriteFactory.h"

using std::string;

class Sprite : public Drawable
{
	public:
		Sprite(const string& n, AbstractFactory* factory = SpriteFrameFactory::getInstance());
		Sprite(const Vector2f& pos, const Vector2f& vel,const string& n, const Frame*);
		Sprite(const Vector2f& pos, const Vector2f& vel,const string& n, AbstractFactory* factory = SpriteFrameFactory::getInstance());
		Sprite(const Sprite& s);
		virtual ~Sprite() { } 
		Sprite& operator=(const Sprite&);
		const string& getName() const { return name; }
		void setName(const string& n) { name = n; }

		virtual const Frame* getFrame() const { return frame; }
		virtual void setFrame(const Frame* f) { frame = f; }
		virtual void draw() const;
		virtual void update(Uint32 ticks);
		unsigned getPixel(Uint32, Uint32) const;

		Vector2f getCenter() const { 
			return Vector2f( X()+frame->getWidth()/2, Y()+frame->getHeight()/2 );
		}
		virtual void handleMouseMotion();
		virtual void shoot();
		bool getVisible() {return visible;}
		void setVisible(bool val) {visible=val;}

		Sprite *getOwner() {return owner;}
		void setOwner(Sprite *s) {owner = s;}
		bool isOwner(Sprite *s) { if(owner == s) return true; return false; }

	private:
		

	protected:
		string name;
		const Frame * frame;
		bool visible;
		int getDistance(const Sprite*) const;
		Sprite *owner;
};
#endif
